#include "IRenderDevice.h"

#include "IRenderTarget2D.h"

namespace Rz { namespace Graphics { namespace Render {

void IRenderDevice::SetRenderTarget(IRenderTarget2D* renderTarget)
{
	if (renderTarget == nullptr)
	{
		_renderTargets.Clear();
		return;
	}

	if (_renderTargets.IsEmpty())
	{
		_renderTargets.Add(renderTarget);
	}
	else if (_renderTargets.GetCount() == 1 && _renderTargets.First() != renderTarget)
	{
		_renderTargets[0] = renderTarget;
	}
	else
	{
		_renderTargets.Clear();
		_renderTargets.Add(renderTarget);
	}
}

void IRenderDevice::SetRenderTargets(const Collections::List<Ptr<IRenderTarget2D>>& renderTargets)
{
	if (renderTargets == _renderTargets)
	{
		return;
	}

	_renderTargets.Clear();
	_renderTargets.Add(renderTargets);
}

void IRenderDevice::SetRenderTargets(std::initializer_list<IRenderTarget2D*> renderTargets)
{
	_renderTargets.Clear();

	for (auto& e : renderTargets)
	{
		_renderTargets.Add(e);
	}
	// _renderTargets.FromEnumerable(Collections::InitializerList<IRenderTarget2D*>(renderTargets));
}

} } }
